package gold.enterprise;


class PrintThread implements Runnable {

    private volatile static int count = 0;

    private volatile static Object lock = new Object();

    @Override
    public void run() {
        synchronized (lock) {
            while (count < 30) {
                switch (count % 3) {
                    case 0:
                        System.out.println("X");
                        break;
                    case 1:
                        System.out.println("Y");
                        break;
                    case 2:
                        System.out.println("Z");
                        break;
                }

                ++count;
            }
        }
    }
}

public class AliGroup {

    public static void main(String[] args) {
        new Thread(new PrintThread()).start();
        new Thread(new PrintThread()).start();
        new Thread(new PrintThread()).start();
    }

}
